<?php

use yii\helpers\Html;
use yii\widgets\LinkPager;

/* @var $this yii\web\View */
/* @var $searchModel app\models\QaSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '文章';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="qa-index">
    <h3>今天，你又了解了些什么新知识乃？<a class="btn btn-success" href="<?php echo Yii::$app->urlManager->createUrl(['article/create']); ?>">发布文章</a> </h3>
    <table class="table">
        <ul id="myTab" class="nav nav-tabs" role="tablist">
            <li role="presentation" class=""><a href="<?php echo Yii::$app->urlManager->createUrl(['article']); ?>">最新的</a></li>
            <li role="presentation" class="active"><a href="<?php echo Yii::$app->urlManager->createUrl(['article/hot']); ?>" >最热门</a></li>
        </ul>
        <tbody>
            <?php foreach ($article_list as $row): ?>
                <tr>
                    <td class="w50"><div class="<?php echo $row->recommend ? 'answers' : 'no-answers' ?>"><?php echo $row->recommend; ?><small>点赞</small></div></td>
                    <td class="w50"><div class="views"><?php echo $row['view']; ?><small>浏览</small></div></td>
                    <td>
                        <span><?php echo $row->author->username ?> &nbsp;&nbsp;<?php echo Yii::$app->formatter->asRelativeTime($row->created_at) ?>&nbsp;发布</span><br>
                        <a href="<?php echo Yii::$app->urlManager->createUrl(['article/view', 'id' => $row['id']]); ?>"><?php echo $row['title']; ?></a>
                        <?php foreach ($row->tags($row['id']) as $item): ?>
                            <a class="btn btn-success btn-xs" href="<?php echo Yii::$app->urlManager->createUrl(['tags/show', 'id' => $item->id]); ?>" role="button"><?php echo $item->name ?></a>
                        <?php endforeach; ?>
                    </td>
                </tr>
            <?php endforeach; ?>

            <?php echo LinkPager::widget(['pagination' => $pages]); ?>
        </tbody>
    </table>

</div>
